﻿#ifndef PLCREADTHREAD_H
#define PLCREADTHREAD_H

#include <QThread>
#include <QSemaphore>
#include <QVector>
#include <QString>
#include <QMutex>
#include <QQueue>
#include <QWaitCondition>
#include <QMap>
#include <QVariant>
#include "open62541.h"
class PLCCommOPCUA;
class PLCReadThread : public QThread
{
public:
    explicit PLCReadThread(Open62541* client, PLCCommOPCUA *parent = nullptr);
    void stop();
    //~PLCReadThread();
    //阀门操作接口
    void readValveStatus(int valveChannel);
    void readAllValveStatus();

    //流量计操作接口
    void readFlowRate(int flowmeterChannel);
    void readAllFlowRate();

    //压力计操作接口
    void readPressure(int pressuremeterChannel);
    void readAllPressure();

    //MKS设备操作接口
    void readMKS();


    //温度设备操作接口
    void readTemperature();

    //其他设备操作接口
    void readOtherValveStatus(int valveChannel);
    void readOtherDataValue(int dataChannel);


    //定制型读取接口(HomePage界面使用)
    //void readDataToHomePage();
protected:
    void run() override;
private:
    Open62541* m_client;          //OPC UA客户端实例
    PLCCommOPCUA * m_pParent;
    bool m_isRuning = true;
    int m_interval_msecs = 1000;

    bool m_valveStatus[11];
    int16_t m_flowMeter[9];
    int16_t m_pressureMeter[2];
    int16_t m_temperature[2];
    bool m_otherValveStatus[8];
    int16_t m_otherData[8];
};

#endif // PLCREADTHREAD_H
